// const redux = require('redux')

// const initialState = {
//   counter: 0
// }
// // 创建 reducer
// const reducer = (state = initialState, action) => {
//   switch (action.type) {
//     case "INCREMENT":
//       return { ...state, counter: state.counter + 1 }

//     case "DECREMENT":
//       return { ...state, counter: state.counter - 1 }

//     case "ADD_NUMBER":
//       return { ...state, counter: state.counter + action.num }

//     case "SUB_NUMBER":
//       return { ...state, counter: state.counter - action.num }
      
//     default:
//       return state;
//   }
// }
// // 根据 reducer 创建 store
// const store = redux.createStore(reducer);
// // console.log(store.getState());

// // action
// const action1 = {type: "INCREMENT"};
// const action2 = {type: "DECREMENT"};
// const action3 = {type: "ADD_NUMBER", num: 5};
// const action4 = {type: "SUB_NUMBER", num: 12};

// // 订阅store的修改
// store.subscribe(() => {
//   console.log(store.getState());
// })

// // 派发action
// store.dispatch(action1)
// store.dispatch(action2)
// store.dispatch(action2)
// store.dispatch(action3)
// store.dispatch(action4)

import store from './store/index'
import {
  addAction,
  subAction
} from './store/actionCreators';
store.subscribe(() => {
  console.log(store.getState());
})
store.dispatch(addAction(10));
store.dispatch(subAction(15))
